﻿Imports System.ServiceModel

<ServiceContract(SessionMode:=SessionMode.Allowed)>
Public Interface IMysteryEncryptedService


    <OperationContract()>
    Function HelloWorld() As String

    <OperationContract()>
    Function message(input As WebMessage) As WebMessage

    <OperationContract()>
    Function getPublicKey() As getPublicKeyOutput

    <OperationContract()>
    Function Authenticate(input As AuthenticateInput) As AuthenticateOutput

End Interface



Public Interface IMysteryEncryptedServiceEventHandler

    Function serverPublicKeyNotFound() As Boolean
    Function serverPublicKeyChanged() As Boolean

End Interface

Public Class DefaultEncryptedServiceEventHandler
    Implements IMysteryEncryptedServiceEventHandler


    Public Function serverPublicKeyChanged() As Boolean Implements IMysteryEncryptedServiceEventHandler.serverPublicKeyChanged
        Dim confirm As MsgBoxResult = MsgBox("server have changed Public Key, are you sure of this server?", MsgBoxStyle.OkCancel, "carefull")
        Return confirm = MsgBoxResult.Ok 
    End Function

    Public Function serverPublicKeyNotFound() As Boolean Implements IMysteryEncryptedServiceEventHandler.serverPublicKeyNotFound
        Return True
    End Function
End Class

Public Class WhateverEncryptedServiceEventHandler
    Implements IMysteryEncryptedServiceEventHandler

    Public Property PublicKeyChanged As Func(Of Boolean)
    Public Property PublicKeyNotFound As Func(Of Boolean)

    Public Function serverPublicKeyChanged() As Boolean Implements IMysteryEncryptedServiceEventHandler.serverPublicKeyChanged
        If PublicKeyChanged Is Nothing Then Return True
        Return PublicKeyChanged.Invoke()
    End Function

    Public Function serverPublicKeyNotFound() As Boolean Implements IMysteryEncryptedServiceEventHandler.serverPublicKeyNotFound
        If PublicKeyNotFound Is Nothing Then Return True
        Return PublicKeyNotFound.Invoke()
    End Function
End Class


